import requests
import time

# url = "http://127.0.0.1:8080/addUser"
#
# data = {
#         "user_name":"sulin",
#         "phone_number":"18565325940",
#         "price":100
# }
# #
# res = requests.post(url,json=data)
# print(res.text)
# print(res)

#{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMDg3OGQ5NTUtZTZlOC00ZDQ0LThkMjEtZmMxYWRiNDI2ODE5IiwidXNlcl9uYW1lIjoiIiwiZXhwIjoxNzQxOTQyMDUzfQ._p5L2l5eXZvsPDVeTACBfPSKkB0vg0ngdLmRoyFcOp8","user":{"user_id":"0878d955-e6e8-4d44-8d21-fc1adb426819","user_name":"sulin","phone_number":"18565325940","price":100}}

headers = {
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMDg3OGQ5NTUtZTZlOC00ZDQ0LThkMjEtZmMxYWRiNDI2ODE5IiwidXNlcl9uYW1lIjoiIiwiZXhwIjoxNzQxOTQyMDUzfQ._p5L2l5eXZvsPDVeTACBfPSKkB0vg0ngdLmRoyFcOp8"
}
url = "http://127.0.0.1:8080/search"
params = {
        "name": "哈尔滨日报",
        "title": '''哈医大与哈工大强强联合！研究发现纳米机器人，可在6分钟内清除4毫米静脉血栓！（来源：极光新闻）#哈医大#哈工大#机器人'''
}
response = requests.get(url, params=params, headers=headers)

# 检查响应状态
if response.status_code == 200:
    # 成功响应，输出数据
    print("响应数据:", response.json())
elif response.status_code == 401:
    # 未授权，输出错误信息
    print("未登录:", response.json().get("error"))
elif response.status_code == 400:
    # 请求取消
    print("请求已取消:", response.json().get("error"))
elif response.status_code == 408:
    # 请求超时
    print("请求超时:", response.json().get("error"))
else:
    # 其他错误
    print(f"发生错误，状态码: {response.status_code}, 错误信息: {response.text}")
